
vec2 fixuv(in vec2 uv){
  vec2 p=5.*(uv*2.-iResolution.xy)/min(iResolution.x,iResolution.y);
  return p;
}

vec3 drawGrid(in vec2 p){
  vec3 col;
  vec2 fraction=1.-2.*abs(fract(p)-.5);
  float vw=fwidth(p.x)*1.;
  float hw=fwidth(p.y)*1.;
  // 网格线
  col=mix(col,vec3(.3),smoothstep(vw,vw*.9,fraction.x));
  col=mix(col,vec3(.3),smoothstep(hw,hw*.9,fraction.y));
  col=mix(col,vec3(1.,.3,.4),smoothstep(fwidth(p.x)*2.,fwidth(p.x)*1.95,abs(p.x)));
  col=mix(col,vec3(1.,.3,.4),smoothstep(fwidth(p.y)*2.,fwidth(p.y)*1.95,abs(p.y)));
  return col;
}

vec3 drawArc(in vec2 p,vec3 col){
  float y=sqrt(pow(1.5,2.)-pow(p.x,2.));
  float w=fwidth(p.x)*2.;
  vec2 pos=vec2(p.x,y);
  col=mix(col,vec3(.6,0.,1.),smoothstep(w,w*.9,length(p-pos)));
  return col;
}

vec3 drawSin(in vec2 p,in vec3 col){
  float y=sin(iTime*0.5+p.x);
  float w=fwidth(p.x)*2.;
  vec2 pos=vec2(p.x,3.+y);
  col=mix(col,vec3(1.,0.,.8314),smoothstep(w,w*.9,length(p-pos)));
  return col;
}

vec3 drawCos(in vec2 p,in vec3 col){
  float y=cos(iTime+p.x);
  float w=fwidth(p.x)*2.;
  vec2 pos=vec2(p.x,2.+y);
  col=mix(col,vec3(0.0, 1.0, 0.0),smoothstep(w,w*.9,length(p-pos)));
  return col;
}

vec3 drawSmoothstep(in vec2 p,vec3 col){
  
  float t=1./3.14*7.;
  
  float y=4.+smoothstep(0.,.7,sin(t*(p.x+iTime)));
  
  float w=fwidth(p.x)*2.;
  vec2 pos=vec2(p.x,y);
  
  col=mix(col,vec3(1.,0.,0),smoothstep(w,w*.9,length(p-pos)));
  return col;
}

vec3 drawStep(in vec2 p,in vec3 col){
  float y  =sin( floor(iTime+p.x))/2.-5.5;
    float w=fwidth(p.x)*2.;
  vec2 pos=vec2(p.x,2.+y);
  col=mix(col,vec3(0.0, 1.0, 0.0),smoothstep(w,w*.9,length(p-pos)));
  return col;
}

vec3 drawPow(in vec2 p,in vec3 col){

  return col;
}

void mainImage(out vec4 fragColor,in vec2 fragCoord){
  vec2 p=fixuv(fragCoord);
  vec3 col=drawGrid(p);
  col=drawSmoothstep(p,col);
  col=drawArc(p,col);
  col=drawSin(p,col);
  col=drawCos(p,col);
  col = drawStep(p,col);
  fragColor=vec4(col,1.);
}